package cas.controller;

import cas.pojo.User;
import cas.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.xml.ws.spi.http.HttpExchange;
import java.util.Map;

/**
 * Created by wwu on 2017/4/13.
 */
@Controller
public class MainController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/",method = RequestMethod.GET)
    public String index(ModelMap model){
        return "index";
    }
    @RequestMapping(value = "home",method = RequestMethod.GET)
    public String home(ModelMap model){


        model.addAttribute("username",userService.getUsername());
        return "home";
    }
    @RequestMapping(value = "person",method = RequestMethod.GET)
    public String person(ModelMap model){
        User user = (User) SecurityUtils.getSubject().getSession().getAttribute("user");


        model.addAttribute("user",user);
        return "person";
    }
    @RequestMapping(value = "news",method = RequestMethod.GET)
    public String news(ModelMap model){
        return "news";
    }
}